"""
    Controller for editing migrations, based on `student_migration_for_methodologists_lookup` view.
"""

from mnemoply import model
from mnemoply.controllers.lookup import LookupController, TableCol, TableLookupDataSource
from mnemoply.controllers.crud import CRUDController

class MigrationForMethodologistController(LookupController, CRUDController):
    model_object = model.StudentMigration

    lookup_columns = [
            TableCol(name='student', caption=_('Student')),
            TableCol(name='school_form', caption=_('School form')),
            TableCol(name='student_plan', caption=_('Initial plan student wish')),
            TableCol(name='teacher_plan', caption=_('Teacher wish plan')),
            TableCol(name='initial_plan', caption=_('Result plan')),
            TableCol(name='methodologist_plan', caption=_('Methodologist wish plan')),
            TableCol(name='office', caption=_('Office'), hidden=True),
            TableCol(name='avg_mark', caption=_('Average mark'), hidden=True),
            TableCol(name='behaviour_comment', caption=_('Behaviour comment'), hidden=True),
            TableCol(name='opponents', caption=_('Opponents'), hidden=True),
            TableCol(name='comment', caption=_('Comment'), hidden=True),
            TableCol(name='ed_group', caption=_('Group'), hidden=True),
            TableCol(name='teacher', caption=_('Teacher'), hidden=True),
            TableCol(name='customer', caption=_('Customer'), hidden=True),
            TableCol(name='customer_phone', caption=_('Phone'), hidden=True)
            ]

    view_fields = [
        'studentID', 'agreementID', 'officeID', 'year',
        'groupCacheTitle',
        'planID',
        'teacherID',
        'initialPlanMethodologistWishID',
        'initialPlanTeacherWishID',
        'friends', 'opponents', 'avgMark', 'healthProblems',
        'possibleDayID',
        'behaviourComment', 'comment',
    ]

    edit_fields = [
        'initialPlanMethodologistWishID',
    ]

    def __init__(self, data_source=TableLookupDataSource('student_migration_for_methodologists_lookup')):
        LookupController.__init__(self,
            data_source=data_source,
            columns=self.lookup_columns,
            title=self.model_object.model_title,
        )
        CRUDController.__init__(self, model_object=self.model_object)
        self.title = _("Migration for methodologist")
        self.local_menu = []

exposed = MigrationForMethodologistController()
